package com.jic.veteran.service.impl;

import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.jic.veteran.mapper.UmsMemberLevelMapper;
import com.jic.veteran.mapper.UmsMemberMapper;
import com.jic.veteran.model.UmsMember;
import com.jic.veteran.model.UmsMemberExample;
import com.jic.veteran.model.UmsMemberLevel;
import com.jic.veteran.model.UmsMemberLevelExample;
import com.jic.veteran.service.UmsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员等级管理Service实现类
 * Created by macro on 2018/4/26.
 */
@Service
public class UmsMemberServiceImpl implements UmsMemberService {
    @Autowired
    private UmsMemberMapper umsMemberMapper;
    @Override
    public List<UmsMember> list(String cname,Integer pageSize,Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        UmsMemberExample example = new UmsMemberExample();
        if(StrUtil.isNotEmpty(cname)) {
            example.createCriteria().andCnameLike("%" + cname + "%");
        }
        return umsMemberMapper.selectByExample(example);
    }

    @Override
    public UmsMember getItem(Long id) {
        return umsMemberMapper.selectByPrimaryKey(id);
    }
}
